import Mock from 'mockjs'

// eslint-disable-next-line import/no-anonymous-default-export
export default {
  getMenu: config => {
    const {username,password } = JSON.parse(config.body)
    // 先判断用户是否存在
    // 判断账号和密码是否对应
    if (username === 'admin' && password === 'admin') {
      return {
        code: 20000,
        data: {
          menu: [
            {
              path: '/home',
              name: 'home',
              label: '首页',
              icon: 'HomeOutlined',
              url: '/home/index'
            },
            {
              path: '/mail',
              name: 'mail',
              label: '商品管理',
              icon: 'ShopOutlined',
              url: '/mail/index'
            },
            {
              path: '/user',
              name: 'user',
              label: '用户管理',
              icon: 'UserOutlined',
              url: '/user/index'
            },
            {
              label: '其他',
              path:'/other',
              icon: 'SettingOutlined',
              children: [
                {
                  path: '/other/pageOne',
                  name: 'page1',
                  label: '页面1',
                  icon: 'SettingOutlined',
                  
                },
                {
                  path: '/other/pageTwo',
                  name: 'page2',
                  label: '页面2',
                  icon: 'SettingOutlined',
                  
                }
              ]
            }
          ],
          token: Mock.Random.guid(),
          message: '获取成功'
        }
      }
    } else if (username === 'xiaoxiao' && password === 'xiaoxiao') {
      return {
        code: 200,
        data: {
          menu: [
            {
              path: '/home',
              name: 'home',
              label: '首页',
              icon: 'HomeOutlined',
              url: '/home/index'
            },
            {
              path: '/mail',
              name: 'mail',
              label: '商品管理',
              icon: 'ShopOutlined',
              url: '/mail/index'
            }
          ],
          token: Mock.Random.guid(),
          message: '获取成功'
        }
      }
    } else {
      return {
        code: -999,
        data: {
          message: '密码错误'
        }
      }
    }

  }
}